package com.ruoyi.oos.web.controller.startstop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.druid.util.StringUtils;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.oos.startstop.service.IStartstopRecordCalService;

@Controller
@RequestMapping("/startstop/cal")
public class StartstopRecordCalAction extends BaseController {
	
	 private String prefix = "startstop/record";
	
	 @Autowired
	 IStartstopRecordCalService startstopRecordService;
	 
	 @GetMapping()
	 public String calData() {
		// overrunRecordCalService.calOverrunRecord(DateUtils.addDays(new Date(), -1));
		   return prefix + "/calData";
	 }
	 
	 @PostMapping("calDataJson")
	 @ResponseBody
	 public String calDataJson( String startTime, String endTime) {
		 if(StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
			 return "-1";
		 }
		 endTime =endTime+"";
		 startTime = startTime+" "+"00:00:00";// 计算开始时间
		  endTime = endTime+" "+"23:59:59";// 计算结束时间
		  startstopRecordService.calStartstopRecord(startTime,endTime);
		 return "success";
		 
		
	 }
	 

}
